package com.cleaningcloud.cld.controller.mini;

import com.cleaningcloud.cld.domain.CldAssetsRecord;
import com.cleaningcloud.cld.domain.CldNoticeConfirm;
import com.cleaningcloud.cld.domain.dto.CldAssetsRecordDto;
import com.cleaningcloud.cld.domain.vo.CldAssetsRecordVo;
import com.cleaningcloud.cld.domain.vo.CldNoticeConfirmVo;
import com.cleaningcloud.cld.service.ICldAssetsRecordService;
import com.cleaningcloud.cld.service.ICldAssetsRepairService;
import com.cleaningcloud.cld.service.mini.IMiniSuppliesService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 资产管理 - 小程序接口
 */
@RestController
@RequestMapping("/mini/supplies")
public class MiniSuppliesController  extends BaseController {

    @Autowired
    private ICldAssetsRecordService assetsRecordService;

    @Autowired
    private ICldAssetsRepairService assetsRepairService;

    @Autowired
    private IMiniSuppliesService miniSuppliesService;
    @Operation(description = "查询资产记录")
    @GetMapping("/getSuppliesList")
    public TableDataInfo getNoticeList(CldAssetsRecordDto cldAssetsRecordDto){
        startPage();
        List<CldAssetsRecordVo> list = assetsRecordService.selectCldAssetsRecordList(cldAssetsRecordDto);
        return getMiniDataTable(list);
    }

    @Operation(description = "查询报修详情")
    @GetMapping("/getSuppliesInfo/{recordId}")
    public AjaxResult getSuppliesInfo(@PathVariable Long recordId){
        return success(assetsRepairService.getRepairDetailsByRecordId(recordId));
    }

    @Operation(description = "资产报修")
    @PostMapping("/addSuppliesReport")
    public AjaxResult addSuppliesReport(@RequestBody CldAssetsRecordDto cldAssetsRecordDto){
        return toAjax(miniSuppliesService.addSuppliesReport(cldAssetsRecordDto));
    }

    @Operation(description = "资产维修")
    @PostMapping("/addSuppliesRepair")
    public AjaxResult addSuppliesRepair(@RequestBody CldAssetsRecordDto cldAssetsRecordDto){
        return toAjax(miniSuppliesService.addSuppliesRepair(cldAssetsRecordDto));
    }


}
